package com.heima.article.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.ApArticleConfigMapper;
import com.heima.article.service.ApArticleConfigService;
import com.heima.model.article.pojos.ApArticleConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

@Slf4j
@Service
public class ApArticleConfigServiceImpl extends ServiceImpl<ApArticleConfigMapper, ApArticleConfig> implements ApArticleConfigService {
    @Override
    public void updateByMap(Map map) {
        if (map == null) {
            return;
        }
        boolean isDown = true;
        if (map.get("enable").equals(1)){
            isDown = false;
        }

        update(Wrappers.<ApArticleConfig>lambdaUpdate().set(ApArticleConfig::getIsDown, isDown).eq(ApArticleConfig::getArticleId, map.get("articleId")));
    }
}
